﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using HJT212_Protocol_Server;

namespace HJT212_Protocol_WebServer
{
    public class Global : System.Web.HttpApplication
    {
        #region 字段属性
        public static CommunicationServer server = new CommunicationServer();
        #endregion


        protected void Application_Start(object sender, EventArgs e)
        {
            
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            try
            {
                if (server != null)
                {
                    server.Stop();
                }
            }
            catch (Exception)
            {

                //throw;
            }

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {
            try
            {
                if (server != null)
                {
                    server.Stop();
                }
            }
            catch (Exception)
            {

                //throw;
            }
        }
    }
}